package com.example.mybatisplus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplus.model.domain.Building;
import com.example.mybatisplus.model.domain.Resident;
import com.example.mybatisplus.mapper.ResidentMapper;
import com.example.mybatisplus.model.domain.WhitelistSetting;
import com.example.mybatisplus.model.dto.PageDTO;
import com.example.mybatisplus.model.dto.StudentCountDTO;
import com.example.mybatisplus.model.dto.UnderDTO;
import com.example.mybatisplus.service.ResidentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lxp
 * @since 2024-07-17
 */
@Service
public class ResidentServiceImpl extends ServiceImpl<ResidentMapper, Resident> implements ResidentService {
    @Autowired
    private ResidentMapper residentMapper;


    //园区统计
    @Override
    public int countStudentsByCampusId(Long campusId) {
        return residentMapper.countStudentsByCampusId(campusId);
    }
    public int getUndergraduateCount(String areaname, String campusname) {
        return residentMapper.getUndergraduateCount(areaname, campusname);
    }
    public int getTeacherCount(String areaname, String campusname) {
        return residentMapper.getTeacherCount(areaname, campusname);
    }
    public int getMasterCount(String areaname, String campusname) {
        return residentMapper.getMasterCount(areaname, campusname);
    }
    public int getDoctorCount(String areaname, String campusname) {
        return residentMapper.getDoctorCount(areaname, campusname);
    }
    @Override
    public List<StudentCountDTO> getStudentCountByMajor(String campusName, String areaName) {
        return residentMapper.getStudentCountByMajor(campusName, areaName);
    }
    //房源分配
    public int getCheckedInUndergraduatesCount() {
        return residentMapper.countCheckedInUndergraduates();
    }
    public int getUndergraduatesCount() {
        return residentMapper.countUndergraduates();
    }
    public int getCheckedInMastersCount() {
        return residentMapper.countCheckedInMasters();
    }
    public int getPhdsCount() {
        return residentMapper.countPhds();
    }
    public int getCheckedInPhdsCount() {
        return residentMapper.countCheckedInPhds();
    }
    public int getStaffsCount() {
        return residentMapper.countStaffs();
    }
    public int getCheckedInStaffsCount() {
        return residentMapper.countCheckedInStaffs();
    }
    public int getMastersCount() {
        return residentMapper.countMasters();
    }
    @Override
    public Page<UnderDTO> getUnderBed(UnderDTO underDTO, PageDTO dto) {
        Page<UnderDTO> page = new Page<>();
        page.setCurrent(dto.getPageNo()).setSize(dto.getPageSize());
        baseMapper.findUnderBed(page, underDTO.getAreaName(), underDTO.getBuildingName(), underDTO.getFloor());
        return page;
    }

    @Override
    public Page<UnderDTO> getPostBed(UnderDTO underDTO, PageDTO dto) {
        Page<UnderDTO> page = new Page<>();
        page.setCurrent(dto.getPageNo()).setSize(dto.getPageSize());
        baseMapper.findPostBed(page, underDTO.getAreaName(), underDTO.getBuildingName(), underDTO.getFloor());
        return page;
    }


    @Override
    public Page<UnderDTO> getStaffBed(UnderDTO underDTO, PageDTO dto) {
        Page<UnderDTO> page = new Page<>();
        page.setCurrent(dto.getPageNo()).setSize(dto.getPageSize());
        baseMapper.findStaffBed(page, underDTO.getAreaName(), underDTO.getBuildingName(), underDTO.getFloor());
        return page;
    }


}
